package com.daniel.io.stream;

import java.io.*;

/**
 * 详细说明
 *
 * @author Daniel
 * @version V1.0
 * @date 2020/6/17 09:29
 */
public class TestTestWriter {
    public static void main(String[] args) {
        BufferedReader br = null;
        BufferedWriter bw = null;
        PrintWriter pw = null;
        File file;
        try {
            br = new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\j2se_源码和思维导图\\eclipse\\Lesson21\\src\\stream\\TestFileOutputStream.java"));
            bw = new BufferedWriter(new FileWriter("C:\\Users\\Administrator\\Desktop\\j2se_源码和思维导图\\eclipse\\Lesson21\\src\\stream\\TestFileOutputStream2.java"));
            pw = new PrintWriter(bw);
            String str = null;
            while ((str = br.readLine()) != null) {
                //使用bw输出不会换行，得在调用bw.newLine()才能换行
                // String value = new String(str.getBytes(), "UTF-8");
                // bw.write(value);
                // bw.newLine();

                pw.println(str);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (pw != null) {
                pw.close();
            }
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
